/**
 *****************************************************************************
 * DESC ：. 
 * Author : Junwei Zhang 
 * CREATEDATE ：2012-6-3 
 * MODIFYLIST ：       	Name 			 Date 			Reason/Contents
 * 				------------------------------------------------------ 
 * 				 	Junwei Zhang     2012-6-3		Created.
 ****************************************************************************
 **/
package com.me.test;

import java.awt.Dimension;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import com.me.client.JTalkClient;
import com.me.client.JTalkClientFront;

/**
 * 
 * <br/>
 * 下午2:02:10 2012-6-3
 * 
 * @Author <a href="mailto:mestudying@sina.com">Junwei Zhang</a><br/>
 **/
public class JTalkTester extends TestCase {

	private JTalkClientFront client = new JTalkClientFront(new JTalkClient());

	public static void main(String[] args) {
		junit.textui.TestRunner.run(new JTalkTester());
	}
	
	public static Test suit(){
		return new TestSuite(JTalkTester.class);
	}

	public void testHaveAChatroom() {
		/**
		 * 1,没有一个客户端聊天框; 2,依旧没有聊天框(其实是没显示出来);
		 */
		assertNotNull(client);
	}

	public void testHaveAPreferedSizeChatroom() {
		/**
		 * 1,大小不合适,理想中的宽高分别为400px;
		 */
		double expectedWidth = 400;
		double expectedHeight = 400;
		double delta = 0.0001;
		Dimension d = client.getSize();
		double width = d.getWidth();
		double height = d.getHeight();
		assertEquals(expectedWidth, width, delta);
		assertEquals(expectedHeight, height, delta);
	}

	public void testHaveAMenu() {
		/**
		 * 1,测试有一个菜单; 2,测试菜单有一个名字叫File,File菜单下有两个选项:Settings...和Exit;
		 * 3,Exit菜单可以退出聊天程序;
		 */
		JMenuBar menuBar = client.getJMenuBar();
		assertNotNull(menuBar);
		int count = menuBar.getMenuCount();
		// assertEquals(1, count);
		assertEquals(2, count);
		for(int i = 0; i < count; i++){
			JMenu menu = menuBar.getMenu(i);
			String menuName = menu.getText();
			System.out.println("MenuText------【" + menuName + "】------");
			int itemCount = menu.getItemCount();
			for(int j = 0; j < itemCount; j++){
				JMenuItem menuItem = menu.getItem(j);
				String itemName = menuItem.getText();
				System.out.println("MenuItemText------【" + itemName + "】------");
			}
		}
		
		
		/*int itemCount = menu.getItemCount();
		assertEquals("File", menuName);
		assertEquals(2, itemCount);
		JMenuItem item0 = menu.getItem(0);
		assertEquals("Settings...", item0.getText());
		JMenuItem item1 = menu.getItem(1);
		assertEquals("Exit", item1.getText());*/
	}
	
	public void testCreateAccount() {
		/**
		 * 1,测试创建一个用户;
		 */
		
	}
}
